package com.ruoyi.report.controller;

import java.util.List;

import com.ruoyi.report.service.MonthlyReportService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.report.domain.MonthlyReport;

import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 月度报表Controller
 *
 * @author ruoyi
 * @date 2024-08-13
 */
@RestController
@RequestMapping("/report/report")
public class MonthlyReportController extends BaseController
{
    @Autowired
    private MonthlyReportService monthlyReportService;

    /**
     * 查询月度报表列表
     */
    @GetMapping("/list")
    public TableDataInfo list(MonthlyReport monthlyReport)
    {
        startPage();
        List<MonthlyReport> list = monthlyReportService.selectMonthlyReportList(monthlyReport);
        return getDataTable(list);
    }


    /**
     * 获取月度报表详细信息
     */
    @GetMapping(value = "/{mrid}")
    public AjaxResult getInfo(@PathVariable("mrid") Long mrid)
    {
        return success(monthlyReportService.selectMonthlyReportByMrid(mrid));
    }

    /**
     * 新增月度报表
     */
    @Log(title = "月度报表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MonthlyReport monthlyReport)
    {
        return toAjax(monthlyReportService.insertMonthlyReport(monthlyReport));
    }

    /**
     * 修改月度报表
     */
    @Log(title = "月度报表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MonthlyReport monthlyReport)
    {
        return toAjax(monthlyReportService.updateMonthlyReport(monthlyReport));
    }

/**
 * 统计图
 * */
    @GetMapping("/getMonthlyReport")
    public AjaxResult getMonthlyReport()
    {
        return success(monthlyReportService.selectMonthlyReport());
    }
}
